<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>出库管理</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"	type="text/javascript"></script>
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<script src="${Plugins}/dateUtil.js" type="text/javascript"></script>

<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<!--打印插件-->
<script type="text/javascript" src="${Plugins}/Lodop6.215_CLodop2.090/LodopFuncs.js"></script>
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
	<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
</object>
<!--打印end-->
<style type="text/css">
#searchbar{
   margin-bottom: 10px;
   margin-left:15px;
  }
  input.l-textarea{width:170px;height:20px;font-size:12px;}
  td{
  	font-size:12px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
</style>
<style id="printStyle">
	/* 打印样式  */
	body{margin: 0px;}
	._wrapper{padding-top: 20px;}
	._p1,._p2{width:960px;margin: 0 auto;height:20px;padding-right: 10px;margin-bottom: 10px;}
	._p1 span{float: right;}
	._p2 p{float: right;}
	._buyer,._shop{width:960px;margin: 0 auto;padding: 10px 20px 0;}
	._comprador,._buyerName,._tel{margin-right: 10px;}
	._compradorName,._buyerName1{margin-right: 300px;}
	._address{display:inline-block;margin-top: 10px;}
	._wrapper table{border:2px dotted #ccc;width:960px;margin: 20px auto;border-collapse: collapse;border-spacing: 0;}
	._wrapper table td{border: 2px dotted #ccc;text-align: center;height:30px;}
	._wrapper ._colspan td{text-align: left;}
	._total{margin-left: 20px;margin-right: 140px;}
	._count,._freight,._money,.privilege{margin-right: 10px;}
	._count1,._freight1,.privilege1{margin-right: 146px;}
	.wang,.tel_{margin-right: 10px;}
	.wang1{margin-right: 100px;}
</style>
</head>
<body style="padding:6px; overflow:hidden;">
<div id="printDelivery" style="display: none;">
	<div class="_wrapper">
		<div class="_p1">
			<span>海航通信旗舰店</span>
		</div>
		<div class="_p2">
			<p>
				<span>发货日期：</span><span>2017-01-09</span>
			</p>
			
		</div>
		<div class="_buyer">
			<p>
				<span class="_comprador">买家：</span><span class="_compradorName">hlcwg</span>
				<span class="_buyerName">姓名：</span><span class="_buyerName1">曹伟钢</span>
				<span class="_tel">电话：</span><span class="_tel1">13112112121</span>
			</p>
			<p>
				<span class="_address">地址：</span><span>上海按时交付囧妃酒叟爱打架偶家所迫</span>
			</p>
		</div>
		<table cellspacing="0" cellpadding="0">
			<tr>
				<td>&nbsp;</td>
				<td>宝贝</td>
				<td>规格</td>
				<td>数量</td>
			</tr>
			<tr>
				<td>1</td>
				<td>泰国AIS卡</td>
				<td>快递邮寄</td>
				<td>1</td>
			</tr>
			<tr class="_colspan">
				<td colspan="4">
					<span class="_total">合计：</span>
					<span class="_count">数量:</span><span class="_count1">1</span>
					<span class="_freight">运费:</span><span class="_freight1">1</span>
					<span class="privilege">优惠:</span><span class="privilege1">1</span>
					<span class="_money">实付金额:</span><span class="_money1">1</span>
				</td>
				
			</tr>
		</table>
		<div class="_shop">
			<span class="wang">卖家旺旺:</span><span  class="wang1">海航通信旗舰店</span>
			<span class="tel_">联系方式:</span><span  class="tel_1">17544664656556</span>
		</div>
	</div>
</div>
<div class="navbar">
		<span>您当前的位置：</span>
		出入库管理 &gt; 商品出库管理
</div>
<form action="../../stockmanage/StockController/pageFinderStockOut.do" method="post" >
<div id="searchbar">
<br>
<table  border="0"> 
	<tr>
		<td  width="15%">	
     		出库单号：
     	</td>
     	<td>
     		 <input id="stockOutNo" name="stockOutNo" type="text" value="${stockOut.stockOutNo}"  style="width: 125px"/>&nbsp;&nbsp;
   		</td>
   		<td  width="10%"></td>
		<td  width="15%">	  
    	出库类型：
    	</td>
     	<td>
     		<select  class="l-textarea"  id="stockOutType"  name="stockOutType" style="width: 145px">
		        <option value="">请选择</option>
		        <option value="-1" <c:if test="${stockOut.stockOutType==-1}">selected="selected"</c:if>>包裹销售出库</option>
		        <option value="-2" <c:if test="${stockOut.stockOutType==-2}">selected="selected"</c:if>>采购退换货出库</option>
		  	 	<option value="-3" <c:if test="${stockOut.stockOutType==-3}">selected="selected"</c:if>>次品退货出库</option>
		  	 	<option value="-4" <c:if test="${stockOut.stockOutType==-4}">selected="selected"</c:if>>订单退换货出库</option>
  		  	 	<option value="-5" <c:if test="${stockOut.stockOutType==-5}">selected="selected"</c:if>>调拨出库</option>
		  	 </select>
   		</td>
 	</tr>
 	<tr style="height: 9px">
   		<td colspan="4"></td>
    </tr>
  	<tr>
		<td>	  
    		 出库时间：
     	</td>
     	<td>
	      <input style="width: 125px" id="beginTime" type="text" name="beginTime" readonly="readonly" value="${stockOut.beginTime}" class="Wdate" value="" size="21"
	    	onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,autoPickDate:true,maxDate:'#F{$dp.$D(\'endTime\')||\'2020-10-01\'}'})" >
		</td>
		<td></td>
     	<td>至</td>
     	<td>
    	<input style="width: 145px" id="endTime" type="text" name="endTime" readonly="readonly" value="${stockOut.endTime}" class="Wdate" value="" size="21"
    	onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,autoPickDate:true,minDate:'#F{$dp.$D(\'beginTime\')||\'2013-01-01\'}'})" >
		 &nbsp;
		 <input id="btnOK" type="submit" value="查询" class="l-button-search" />
		 <input type="button" id="resetBtn" value="重置" class="l-button-search" />
		</td>
	</tr>
</table>

</div>
</form>

<div id="maingrid4" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- g data total ttt -->
</div>

<script>
    var basePath='${BasePath}';
	var tabId = window.top.tab.getSelectedTabItemID();
    var grid = null;
    $(function () {
    	 // 重置
        $("#resetBtn").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
        grid = $("#maingrid4").ligerGrid({
            columns: [
            { display: '单号', name: 'stockOutNo',width:120},
            { display: '出库类型', name: 'stockOutType',render:function(rowdata,rowindex,value){

            	var text=null;
	            switch(value){
		            case -1 : text="包裹销售出库"; break;
		            case -2 : text="采购退换货出库"; break; 
		            case -3 : text="次品退货出库"; break;  
		            case -4 : text="订单退换货出库"; break;  
		            case -5 : text="调拨出库"; break;  
		            default : break;
	            }
            return text;
        	}},
            { display: '收货人', name: 'receiverName'},
            { display: '创建时间', name: 'createTime',render: function(rowdata, rowindex, value){
     		   	if(value == '' || value == null){
     				return  "";
     			}
     			return getFormatDateByLong(value, "yyyy-MM-dd hh:mm:ss");
     		}},
            { display: '出库时间', name: 'updateTime',render: function(rowdata, rowindex, value){
     		   	if(value == '' || value == null){
     				return  "";
     			}
     			return getFormatDateByLong(value, "yyyy-MM-dd hh:mm:ss");
     		}},
            { display: '出库人员', name: 'updater'},
            { display: '出库状态', name: 'stockOutState',render:function(rowdata,rowindex,value){
	            var text=null;
		            switch(value){
			            case 1 : text="已出库"; break;
			            case 0 : text="未出库"; break;       
			            default : break;
		            }
	            return text;
            }},
            { display: '操作',name:'stockOutState',isSort: false, render: function (rowdata, rowindex, value){
            	
            	if(value == 0){
            		return "<a id = 'operate1' href='javascript:toStockOutApprove(" + rowindex + ")'>出库</a>&nbsp;&nbsp;";
            	}else{
            		var operateButton = "";
            		if(rowdata.productFetchType == 1){
	            		var logisticsNo = rowdata.logisticsNo;
	            		var logisticsOrder = rowdata.logisticsOrder ;
	            		operateButton += "<a id = 'operate2' target='_blank' href='http://www.kuaidi100.com/chaxun?com="+logisticsNo+"&nu="+logisticsOrder+"'>查询物流</a>&nbsp;&nbsp;";
	            		//打印A4纸发货信息功能暂屏蔽      时间2017-1-10 tangou
	            		//operateButton += "<a id = 'operate3' href='javascript:toPrintStockOut(" + rowindex + ")'>打印</a>&nbsp;&nbsp;";
            		}
            		return operateButton + "<a id = 'operate3' href='javascript:toStockOutDetail(" + rowindex + ")'>详细</a>&nbsp;&nbsp;";
            	}
            }}
            ],
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
					{name: "stockOutNo", value:$("#stockOutNo").val()},
					{name: "stockOutType", value:$("#stockOutType").val()},
					{name: "beginTime", value:getFullTime($("#beginTime").val(),true)},
					{name: "endTime", value:getFullTime($("#endTime").val(),false)}
                    ],
             url: "ajaxPageFinderStockOut.do",
             toolbar: {items: [{ text: "导出EXCEL", click: exportExcel, icon: "up" },{line: true}]}	
        });
    });
   
/*   function detailOrderCheck(rowindex){
	  var stockOutNo=grid.getData()[rowindex].stockOutNo;	 
	  var m=$.ligerDialog.open({title:'详情',url:basePath+"/stockmanage/StockController/toStockOutDetail.do?stockOutNo="+stockOutNo,height:400,width:800,isResize: false, isDrag: false });
	  m.show();
     
  } */
  
    //打印发货明细
    function toPrintStockOut(rowindex){
	  $.ligerDialog.confirm('确定打印吗?', function(yes) {
			if (yes) {
				$("#printDelivery").show();
				printStockInfo();
			}else{
				$("#printDelivery").hide();
			}
		});
	}
  
  	function toStockOutDetail(rowindex){
  		var stockOutNo = grid.getData()[rowindex].stockOutNo;	 
		var url=  basePath+'/stockmanage/StockController/toStockOutDetail.do?tabId=' + tabId +'&stockOutNo=' + stockOutNo;
		window.parent.f_addTab('详情','详情',url);
  	}
	function toStockOutApprove(rowindex){
		var stockOutNo = grid.getData()[rowindex].stockOutNo;	 
		var url=  basePath+'/stockmanage/StockController/toStockOutApprove.do?tabId=' + tabId +'&stockOutNo=' + stockOutNo;
		window.parent.f_addTab('出库','出库',url);
	}  
	function queryLogistics(rowindex){
		var stockOutNo = grid.getData()[rowindex].stockOutNo;	 
		var url=  basePath+'/stockmanage/StockController/toStockOutApprove.do?tabId=' + tabId +'&stockOutNo=' + stockOutNo;
		window.parent.f_addTab('出库','出库',url);
		queryLogistics
	}  
	
	//调用lodop打印插件
	function printStockInfo() {
        var LODOP = getLodop();
        LODOP.PRINT_INIT("自定义名称，打印的识别标记");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");//定义纸张，方向
        var strStyleHtml = "<style>"+document.getElementById("printStyle").innerHTML+"</style>";
        var strDivHtml = "<body>"+document.getElementById("printDelivery").innerHTML+"</body>";
        LODOP.ADD_PRINT_HTM(0,30,"100%","100%", strStyleHtml+strDivHtml);//定义打印的内容与位置
        LODOP.PREVIEW();
    }
	
	/*
	 *导出EXCEL
	*/
	function exportExcel(){
		var exportUrl = '${BasePath}/stockmanage/StockController/exportStockOut.do';
		var params = [{name: "stockOutNo", value:$("#stockOutNo").val()},
						{name: "stockOutType", value:$("#stockOutType").val()},
						{name: "beginTime", value:getFullTime($("#beginTime").val(),true)},
						{name: "endTime", value:getFullTime($("#endTime").val(),false)}];
	     var form = $("<form>");   //定义一个form表单
	     form.attr('style', 'display:none');   //在form表单中添加查询参数
	     form.attr('target', '');
	     form.attr('method', 'post');
	     form.attr('action', exportUrl);
	     for(var i=0;i<params.length;i++){
	     	var input = $('<input>');
	         input.attr('type', 'hidden');
	         input.attr('name', params[i].name);
	         input.attr('value', params[i].value);
	         form.append(input);   //将查询参数控件提交到表单上
	     }
	     $('body').append(form);  //将表单放置在web中 
	     form.submit();
	     form.remove();
	 }
	
</script>
</body>
</html>